package config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.stereotype.Component;
import service.SysUserService;

import javax.annotation.Resource;

/**
 * @Description: 监听session,
 * @Author: liujh
 * @Date:
 * @UpdateUser: liujh
 * @Date: 2020/09/24$ 15:30$
 * @UpdateRemark:
 * @Version: 1.0
 */

@Component
@Slf4j
public class RedisSessionListener extends KeyExpirationEventMessageListener  {



    /**
     * Creates new {@link } for {@code __keyevent@*__:expired} messages.
     *
     * @param listenerContainer must not be {@literal null}.
     */
    public RedisSessionListener(RedisMessageListenerContainer listenerContainer) {
        super(listenerContainer);
    }

    @Override
    public void onMessage(Message message, byte[] pattern) {
        String expiredKey = message.toString();
        log.info("session过期========="+expiredKey);

    }




}
